package ws.jdbc.concurrent.driver.sqlserver.tds

import ws.jdbc.concurrent.driver.sqlserver.tds.datatypes.*
import ws.utils.io.LittleEndianDataInputStream

/**
 * Test of DataTypeDependentDataStreamReader methods.
 *
 * @author Wilson Santos, 36228 <wilson.santos@ua.pt>
 */
class DataTypeDepentDataStreamReaderTest extends CommonOfflineTest {

  /**
   * Test of read TYPE_VARBYTE method.
   */
  void testReadTypeVarByte() {
    println "testReadTypeVarByte"

    def data = [
      0x03, 0x00, 0x66, 0x6F, 0x6F
    ] as Byte[]

    sendData(data)
    def is = receiveData()
    def sreader = new DataTypeDependentDataStreamReader(is)
    def info = new TypeInfoVarLenType(VARLENTYPE.BIGVARCHRTYPE, 0)

    def value = sreader.readTypeVarByte(info)

    assertEquals data.length, sreader.getBytesRead()
    assertEquals 3, value.type_varlen.length

    println value.dataBuffer.array()
  }
}